Pre-Defined Actions

Description

Common operations have been built-in to Alpha Anywhere as Pre-Defined Actions, allowing you to quickly add these operations to your desktop applications using Action Scripting.

Some of the examples in this guide require the "Learning Action Scripting" workspace. See Creating Your First Action Script to learn how to get the "Learning Action Scripting" workspace installed.

When you put a button on a form, Alpha Anywhere let's you define the Action for the button in one of three ways. You can:

  • Pick a pre-defined Action
  • Use the Action Scripting Editor
  • Use the Xbasic Code Editor

If you want a very simple button that performs a single step, the "Pre-Defined Actions" are perfect. Every command appearing on the Form menus is available as a Pre-Defined button. For example, put four buttons on a form to navigate to the first, previous, next and last record.

  1. Activate the Control Panel.

  2. Select the Tables/Sets tab.

  3. Right-click the "Customer" table and select Open Default Form.

  4. Click the Design button to switch to Design Mode. Your screen should now look like this:

    images/Pre_Defined_Actions_1.gif
    The Button Object tool in the Toolbox will place a button on the form. If you don't see the Toolbox, click Toolbox on the View menu.
  5. Select the Button Object tool  on the Toolbox.

  6. While holding down the left mouse button, draw a small button on the form to the right of the Customer Id field. When you release the mouse, the Define Button dialog box appears:

    images/Define_Button_Default_Settings.gif
  7. Click the Pre-defined Buttons tab on the dialog box. The following list appears. This list exactly mirrors the form menus available when you're viewing a form.

    images/Pre_Defined_Actions_3.gif
  8. Click the + icon to expand the "Records" category.

  9. Select "First" record and click OK. Alpha Anywhere puts a button on the form, as shown below:

    images/Pre_Defined_Actions_4.gif
  10. Repeat these steps three times, selecting the "Previous", "Next" and "Last" record commands. Your form should now look like this:

    images/Pre_Defined_Actions_5.gif
  11. Click the Save button to save the form and name it "Navigate."

  12. Click the Form View button to switch to Form View Mode and test your buttons.

  13. Put the form back into Design Mode by clicking the Design button.

  14. Right-click the first button (the First Record button), select Events and OnPush.

The Events right-click menu lists the various events for the current object (i.e. the button that you have selected). Note that only the OnPush event appears in bold type. That's because the OnPush event has already been defined.
images/Pre_Defined_Actions_6.gif

The Code Editor opens and shows the script associated with the button's OnPush event.

This should look familiar. A Pre-Defined button action is a short cut for creating a simple action script with one action. The action is "Select Action from the Form Menu".

Pay particular attention to the name of the tab. You assigned the name "Navigate" to the form when you saved it. The name of the button object is "Button1." The event name is OnPush. Alpha Anywhere automatically assigned the button object name when you drew the button on the form.

You are free to change the name of any object on a form by right-clicking the object and selecting Properties... > Setup. and changing the Object Name.

Limitations

Desktop Applications Only